1. Field of Invention
The present invention relates to a method of real-time recording a multimedia file. More particularly, the present invention relates to a method of real-time recording an AVI-format file on an optical storage medium.
2. Description of Related Art
AVI is a windows media file format for sound and dynamic pictures used in RIFF specification developed by Microsoft Corporation. AVI is the abbreviation of Audio Video Interleaved, and RIFF is the abbreviation of Resource Interchange File Format.
First, the RIFF specification is described. As shown in FIG. 1A, the RIFF file format comprises an “RIFF”, a length, an identifier and a data region. The “RIFF” is a four-character code (FCC). As the byte sequence of the Microsoft operation system employs a little-endian method, if the codes of the four-character code “RIFF” are represented as 52 49 46 46 in hexadecimal, the sequence of writing into the file is 46 46 49 52. For the convenience of recognition, the following four-character codes are all marked with double quotation marks. The RIFF file format includes: first, a four-character code “RIFF” of 4 bytes indicating that this is a RIFF file; next, 4 bytes indicating the length of the RIFF file; then, the four-character code of 4 bytes serving as the identifier to indicate the data type (such as AVI or WAVE); and last, the data region being used for storing actual data. It should be noted that the value recorded in the length field is the length of the actual data (i.e. the length of the data region) plus the length of the identifier field (i.e. 4 bytes).
Additionally, the RIFF specification adopts two types of data format, namely list and chunk, and the list/chunk can further nest other lists/chunks. As shown in FIG. 1B, a list format comprises a “LIST”, a length, an identifier and a data region. “LIST” is a four-character code indicating that this is a list. The value recorded in the length field is the length of the data region plus the length of the identifier field. The identifier is, for example, a four-character code such as “hdrl” and “movi”, indicating the data type. Similarly, a chunk format comprises an identifier, a length and a data region. The identifier is, for example, a four-character code such as “idx1”, indicating the data type. The length recorded in the length field is the length of the data region plus the length of the identifier field.
Next, an AVI file format is described. AVI is a windows media file format using the RIFF specification. As shown in FIG. 2A, the AVI file format includes: first, the four-character code “RIFF” indicating that this is an RIFF file; next, len1 indicating the length of this file; then, the four-character code “AVI” indicating that this is an AVI file, wherein the four-character code containing space is legal; and last, the data region being used for storing actual AVI data. Usually, the part preceding the data region is called the header. For example, a header 20 of the AVI file format comprises an “RIFF”, a length lent and an identifier “AVI”. Further, the data region of the AVI file format comprises two lists 21, 22 and an optional chunk 23. The format of the list 21 comprises a “LIST”, a length len2, an identifier “hdrl” and an HDRL data region (for storing every header data of digital audio/video data). The format of the list 22 comprises a “LIST”, a length len3, an identifier “movi” and an MOVI data region (for storing the above-mentioned digital audio/video data). The format of the chunk 23 comprises an identifier “idx1”, a length len4 and an IDX1 data region (for storing index data used for fast-forward, rewind, etc.).
Additionally, the file system of an optical disc is described below, taking ISO 9660 as an example. The ISO 9660 file system allows a file to be constituted of one or more discrete fragments. In the file system, each file fragment has a multi-extent bit to indicate whether the fragment is the last fragment of the file. If the storage medium space used by the file is continuous and sequential, the file has only one fragment, and the multi-extent bit in the file system is 0. If the storage medium space used by the file is discrete, the file has multiple fragments, and the file system is used to connect the discrete fragments into one logically continuous file, which is the recording manner of a multi-section file.
In the case of real-time recording an AVI-format file on an optical storage medium and adopting an optical disc file system without the multi-section record, the storage medium space used by a file must be continuous and sequential. In addition, the file has only one fragment and does not need to lookup the file system for the addresses of the other discrete fragments. As the list 22 is used for storing real-time recorded digital audio/video data, the value in length field len3 of the list 22 cannot be obtained until recording is stopped. Thus the space for recording header of the list 22 (including the “LIST”, length field len3 and identifier “movi”) must be reserved, and the recorded data are first written into the MOVI data region of the list 22. After recording, the header data related to the recorded digital audio/video data are filled into the header of the list 21.
Additionally, as for a write-once optical storage medium such as DVD+/−R, a linking loss area which data cannot be written into is generated at the end point of each continuous recording, so as to finish the current continuous recording action. Generally, the length of this linking loss area is 2 KB or 32 KB, and all the data read from this area can be regarded as zero. Thus, the linking loss area exists between every continuous recording area. In the above situation, as shown in FIG. 2B, the linking loss area exists between the MOVI data region and the header of the list 22. When a play program or a player is attempting to read the first A/V chunk of list 22, it will get a series of zero because of the linking loss area, and thus incur error.
Since a player locates the start point of the next list/chunk, based on the length of current list/chunk recorded in the header, for an AVI file. If the length recorded in the chunk/list header is not matching the actual length, the AVI file cannot be accurately parsed. Therefore, if this situation is not specifically treated, then the linking loss area produced in the file may destroy the format and the accuracy. Although currently the multi-section record can be used in real-time recording, it writes the list 21 after the list 22 and the chunk 23 and then connects the discrete fragments into a logically continuous section by use of the file system. However, the method of using multi-section record is not popular in the current market and is not fully supported. Or, each recording length of the AVI file is restricted, so as to obtain an accurate AVI-format file during real-time recording, but the method of restricting the length of each recording is not convenient in use.